<?php

/**
 * Created by PhpStorm.
 * User: evan
 * Date: 16/9/21
 * Time: 上午2:34
 */
class Base extends MY_Api_Controller
{
    public function success()
    {
    	$uid = $this->uid;
    	$type = (int)$this->input->get_post('type');
    	$channel = (int)$this->input->get_post('channel');
    	
    	$this->load->model('share/Model_share_log', 'sl');
    	
    	$data = array(
    			'uid'=>$uid,
    			'type'=>$type,
    			'channel'=>$channel,
    			'ip'=>$this->input->ip_address(),
    			'create_time'=>date('Y-m-d H:i:s'),
    	);
    	
    	$sid = $this->sl->save($data);
    	
    	$log_num = $this->sl->count(array('uid' => $uid, 'type'=>$type, 'create_time >' => date('Y-m-d', TIMESTAMP).' 00:00:00'));
    	
    	if ($log_num == 1)
    	{
    		$this->load->service('excitation/service_excitation_base');
	        $param = array
	        (
	            'uid'  => $uid,
	            'type' => EXCITATION_TYPE_SHARE,
	            'sid'  => $sid,
	        );
	        $this->service_excitation_base->grant($param);
    	}
    	
    	
    	
    	$this->json_output(array());
    }
}